home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig05_17.jar / Ch05 / Fig05_17 / Fig05_17.cpp next >
C/C++ Source or Header  |  1997-10-14  |  1KB  |  44 lines

  1. // Fig. 5.17: fig05_17.cpp
  2. // Demonstrating the sizeof operator
  3. #include <iostream.h>
  4. #include <iomanip.h>
  5.  
  6. int main()
  7. {
  8.    char c;
  9.    short s;
  10.    int i;
  11.    long l;
  12.    float f;
  13.    double d;
  14.    long double ld;
  15.    int array[ 20 ], *ptr = array;
  16.  
  17.    cout << "sizeof c = " << sizeof c
  18.         << "\tsizeof(char) = " << sizeof( char )
  19.         << "\nsizeof s = " << sizeof s
  20.         << "\tsizeof(short) = " << sizeof( short )
  21.         << "\nsizeof i = " << sizeof i
  22.         << "\tsizeof(int) = " << sizeof( int )
  23.         << "\nsizeof l = " << sizeof l
  24.         << "\tsizeof(long) = " << sizeof( long )
  25.         << "\nsizeof f = " << sizeof f
  26.         << "\tsizeof(float) = " << sizeof( float )
  27.         << "\nsizeof d = " << sizeof d
  28.         << "\tsizeof(double) = " << sizeof( double )
  29.         << "\nsizeof ld = " << sizeof ld
  30.         << "\tsizeof(long double) = " << sizeof( long double )
  31.         << "\nsizeof array = " << sizeof array
  32.         << "\nsizeof ptr = " << sizeof ptr
  33.         << endl;
  34.  
  35. void * ptr1;
  36. int * ptr2;
  37.  
  38. ptr1 = ptr2;
  39. ptr2 = ptr1;
  40.  
  41.    return 0;
  42. }
  43.  
  44.